<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<jsp:useBean id="photo" class="image.images" scope="session" />

<%
 
  int iNumPhoto ;
	
// Referencia de conexi?n a una BD con JDBC.
	Connection con = null;

 
  if ( request.getParameter("imgID") != null )
  {
  
    iNumPhoto = Integer.parseInt(request.getParameter("imgID")) ;  
 
    try
    { 
       con = DriverManager.getConnection("jdbc:mysql://localhost/insacosa_carrito","insacosa_root","tivoli00");;
       con.setAutoCommit (false); 
 
       // get the image from the database
       byte[] imgData = photo.getPhoto(con,iNumPhoto  ) ;  
       // display the image
       response.setContentType("image/gif");
       ServletOutputStream o = response.getOutputStream();

       o.write(imgData);
       o.flush();
       o.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw e;
    }
    finally
    {
    	con.close();    	

    } 
  }
%>